<?php

/**
 * Node URL alias validator
 *
 */
class Application_Form_NodeUrlValidator extends Zend_Validate_Abstract
{
    protected $_messageTemplates = array(
        'invalidURL' => "URL '%value%' is invalid"
    );
    
    /**
     * Validate interface isValid function
     *
     * @param string $value
     * @return bool
     */
    public function isValid($value)
    {
        if (empty($value)) return false;
        
        $this->_setValue($value);
        
        if (!preg_match('/^[a-zа-я0-9_-]{3,255}$/iu',$value)) 
        {
            $this->_error('invalidURL');
            return false;
        }

        return true;
    }
}